<template>
    <div>
      <p :style='{opacity}'>vue真难</p>
      <button @click="destory">手撕它</button>
    </div>
</template>

<script>
export default {
  name:'App',
  data(){
    return {
      opacity:1,
      timer: null
    }
  },
  methods:{
    destory(){
      this.$destroy()
    }
  },
  mounted() {
    this.timer = setInterval(() => {
      this.opacity -= 0.1
      if(this.opacity <=0){
        this.opacity = 1
      }
    }, 200);
    console.log(1);
  },
  beforeDestroy(){
    clearInterval(this.timer)
  }
}
</script>

<style>

</style>